<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Language extends CI_Controller {
	function __construct() {
		parent::__construct();
	}

	function index() {
		$language_code = $this->input->post('language_code');

		if (isset($language_code) && $language_code != "") {
			$data = array(
                'language_code' => $language_code
			);

			$this->session->set_userdata($data);

			$redirect = $this->input->post('redirect');

			//check is logged in
			$this->load->model('languagemodel');
			$this->language = $this->languagemodel->is_language_using();

			$this->lang->load('common/header', $this->language);
			$data['text_max'] = $this->lang->line('text_max');
			$data['text_min'] = $this->lang->line('text_min');
			$data['text_free_text'] = $this->lang->line('text_free_text');

			$redirect = urldecode($redirect);

			if ($redirect) {
				redirect($redirect);
			} else {
				redirect('home');
			}
		}
	}
}
?>
